/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejemplojavaex;

import java.awt.TextField;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.layout.AnchorPane;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLista;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLocal;
import mx.edu.itschapala.sistemas.septimo.modelo.Cliente;

/**
 * FXML Controller class
 *
 * @author Miguel Romero
 */
public class RegistrarClienteController implements Initializable {

    @FXML
    private AnchorPane ventanaRC;
    @FXML
    private TextField codigo;
    @FXML
    private TextField nombre;
    @FXML
    private TextField sexo;
    @FXML
    private TextField telefono;
    @FXML
    private TextField direccion;
    
    @FXML
    public void ventanaListarClientes(){
        try{
            Parent root = FXMLLoader.load(getClass().getResource("ListarClientes.fxml"));
            ventanaRC.getScene().setRoot(root);
        }catch (IOException e){
            System.out.println("Error al cargar la ventana de menu");
        }
        
    }
    @FXML
    public void RegistrarCliente(){
       
        Cliente c = new Cliente( 
                nombre.getText(),
                sexo.getText(),
                Integer.parseInt(codigo.getText()),
                Integer.parseInt(telefono.getText()), 
                direccion.getText()
                );
        
        ClienteLnLocal cln = ClienteLnLista.getIsnstnciaC();
        cln.clienregistrar(c);
        
    }
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
